package com.liruo.learn.spring.mvc.controller.m1handlermapping;

import java.util.Collections;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;

/**
 * @Author:liruo
 * @Date:2023-10-05-19:02:36
 * @Desc
 */
@Configuration
public class URLSimplelController {
  @Bean
  public SimpleUrlHandlerMapping mSimpleUrlHandlerMapping() {
    return new SimpleUrlHandlerMapping(
        Collections.singletonMap(URLSimplelController.class.getSimpleName(),
            new Controller()), -1);
  }
  public class Controller implements org.springframework.web.servlet.mvc.Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
      response.getWriter().write(URLSimplelController.class.getSimpleName());
      return null;
    }
  }
}
